package controllers;

import java.io.IOException;
import java.util.Date;

import javax.servlet.http.*;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.Text;

@SuppressWarnings("serial")
public class ExampleSet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/plain");
		
		DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();		
		
		Entity domain = new Entity("Domain", "google.com.vn");
			
		domain.setProperty("title", new Text("Search google"));

		Date lastUpdate = new Date();
		domain.setProperty("lastUpdate", new Text(String.valueOf(lastUpdate.getTime())));
		datastore.put(domain);
		
		resp.getWriter().println("Add success" + domain.getProperty("key"));
		
	}
}
